using Sandia.MVCFramework.View;
using System;
using System.Collections.Generic;
using System.Text;

namespace Sandia.MVCFramework.ViewManager
{
    /// <summary>
    /// A layout node used for constructing a linked list of nodes.
    /// </summary>
    public class LinkedListLayoutNode : ILayoutNode
    {
        /// <summary>
        /// The internal parent of the node.
        /// </summary>
        private ILayoutNode parent;

        /// <summary>
        /// The internal child of the node.
        /// </summary>
        private ILayoutNode child;

        /// <summary>
        /// The view for this node.
        /// </summary>
        private IView view;

        /// <summary>
        /// The percent of the screen that this view should take up when the 
        /// layout occurs.
        /// </summary>
        private int width;

        /// <summary>
        /// Constructor for the LinkedListLayoutNode.
        /// </summary>
        /// <param name="view">The view for this node.</param>
        /// <param name="child">The child of the node.</param>
        /// <param name="width">The parent of the node.</param>
        public LinkedListLayoutNode(
            IView view,
            ILayoutNode child,
            int width)
        {
            this.view = view;
            this.child = child;
            this.width = width;
            if (this.child != null)
            {
                this.child.Parent = this;
            }
        }

        /// <summary>
        /// The child of the node.
        /// </summary>
        public ILayoutNode Child
        {
            get { return this.child; }
            set { this.child = value; }
        }

        #region ILayoutNode Members

        /// <summary>
        /// The parent of the node.
        /// </summary>
        public ILayoutNode Parent
        {
            get { return this.parent; }
            set { this.parent = value; }
        }

        #endregion

        /// <summary>
        /// The percent of the screen that this view should take up when the 
        /// layout occurs.
        /// </summary>
        public int Width
        {
            get { return this.width; }
            set { this.width = value; }
        }

        /// <summary>
        /// The view for this node.
        /// </summary>
        public IView View
        {
            get { return this.view; }
            set { this.view = value; }
        }
    }
}
